package com.wjb.xietong.server.task;

import org.json.JSONObject;
import com.wjb.xietong.server.BaseResponseDataParse;
import com.wjb.xietong.server.HeaderInfoResponse;
import com.wjb.xietong.util.IDs;
import com.wjb.xietong.util.LogD;

public class UpdateTaskStatuResponse extends BaseResponseDataParse {

	private static UpdateTaskStatuResponse instance = null;
	private HeaderInfoResponse headerInfo = null;

	private UpdateTaskStatuResponse() {

	}

	public static synchronized UpdateTaskStatuResponse instance() {
		if (null == instance) {
			instance = new UpdateTaskStatuResponse();
		}
		return instance;
	}

	@Override
	public void initData() {
		setHeaderInfo(null);
	}

	@Override
	public boolean parseJsonObj(JSONObject response) {
		initData();
		if (null == response) {
			LogD.output("Exception: response is null");
			return false;
		}

		if (!checkRespCode(response)) {
			headerInfo = new HeaderInfoResponse();
			headerInfo.parseJsonObj(response);
			setHeaderInfo(headerInfo);
			return false;
		}

		boolean result = response.optBoolean(IDs.FINISH_TASK_RESULT);
		return result;
	}

	public HeaderInfoResponse getHeaderInfo() {
		return headerInfo;
	}

	public void setHeaderInfo(HeaderInfoResponse headerInfo) {
		this.headerInfo = headerInfo;
	}
}
